/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package main.java.com.giftmemo.ui.add;

import com.alee.extended.panel.WebCollapsiblePane;
import com.alee.laf.combobox.WebComboBox;
import com.alee.laf.text.WebFormattedTextField;
import com.alee.laf.text.WebTextField;
import com.giftmemo.ui.utils.ButtonsPanel;
import java.awt.BorderLayout;
import javax.swing.Action;
import javax.swing.BorderFactory;
import javax.swing.Box;
import javax.swing.JPanel;

/**
 *
 * @author Egor
 */
public class AddGiftPanel extends JPanel {

    private WebComboBox typeOfGiftComboBox;
    private WebTextField giftDescriptionTextField;
    private WebTextField shopNameTextField;
    private WebFormattedTextField giftPriceTextField;
    private WebCollapsiblePane previousGiftsDirectory;
    private ButtonsPanel buttonsPanel;

    public AddGiftPanel() {
        typeOfGiftComboBox = new WebComboBox();
        giftDescriptionTextField = new WebTextField();
        shopNameTextField = new WebTextField();
        giftPriceTextField = new WebFormattedTextField();
        buttonsPanel = new ButtonsPanel(ButtonsPanel.ButtonsPanelState.OK_BUTTON, ButtonsPanel.ButtonsPanelState.CANCEL_BUTTON);
        previousGiftsDirectory = new WebCollapsiblePane();
        init();
    }

    private void init() {
        setLayout(new BorderLayout(5, 5));

        Box giftTypeAndDescription = Box.createHorizontalBox();
        giftTypeAndDescription.add(typeOfGiftComboBox);
        giftTypeAndDescription.add(Box.createHorizontalStrut(5));
        giftTypeAndDescription.add(giftDescriptionTextField);

        giftTypeAndDescription.setBorder(BorderFactory.createTitledBorder("Описание и Тип"));

        Box shopAndPrice = Box.createHorizontalBox();
        shopAndPrice.add(shopNameTextField);
        shopAndPrice.add(Box.createHorizontalStrut(5));
        shopAndPrice.add(giftPriceTextField);
        shopAndPrice.setBorder(BorderFactory.createTitledBorder("Магазин и Цена"));

        Box giftAndShopInformation = Box.createVerticalBox();
        giftAndShopInformation.add(giftTypeAndDescription);
        giftAndShopInformation.add(Box.createVerticalStrut(5));
        giftAndShopInformation.add(shopAndPrice);

        Box previousGifts = Box.createHorizontalBox();
        previousGifts.add(previousGiftsDirectory);
        previousGifts.setBorder(BorderFactory.createTitledBorder("Предыдущие подарки"));

        add(giftAndShopInformation, BorderLayout.CENTER);
        add(previousGifts, BorderLayout.EAST);
        add(buttonsPanel, BorderLayout.SOUTH);
    }

    public void setAddButtAction(Action addButtonAction) {
        buttonsPanel.setOkButtonAction(addButtonAction);
    }

    public void setCancelButtonAction(Action cancelButtonAction) {
        buttonsPanel.setCancelButtonAction(cancelButtonAction);
    }
}
